{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 创建人脸集合\n",
    "face =[{'faceId': '87940b45-7f46-4f76-8dac-65b828485857',\n",
    "  'faceRectangle': {'top': 38, 'left': 46, 'width': 49, 'height': 49},\n",
    "  'faceAttributes': {'smile': 1.0,\n",
    "   'gender': 'male',\n",
    "   'age': 30.0,\n",
    "   'glasses': 'NoGlasses',\n",
    "   'hair': {'bald': 0.06,\n",
    "    'invisible': False,\n",
    "    'hairColor': [{'color': 'brown', 'confidence': 1.0},\n",
    "     {'color': 'black', 'confidence': 0.83},\n",
    "     {'color': 'red', 'confidence': 0.29},\n",
    "     {'color': 'gray', 'confidence': 0.12},\n",
    "     {'color': 'blond', 'confidence': 0.1},\n",
    "     {'color': 'other', 'confidence': 0.06},\n",
    "     {'color': 'white', 'confidence': 0.0}]}}},\n",
    " {'faceId': 'eb5ce895-d9d1-47a4-a857-d21999f10e65',\n",
    "  'faceRectangle': {'top': 63, 'left': 99, 'width': 43, 'height': 43},\n",
    "  'faceAttributes': {'smile': 1.0,\n",
    "   'gender': 'female',\n",
    "   'age': 32.0,\n",
    "   'glasses': 'NoGlasses',\n",
    "   'hair': {'bald': 0.78,\n",
    "    'invisible': False,\n",
    "    'hairColor': [{'color': 'brown', 'confidence': 0.9},\n",
    "     {'color': 'black', 'confidence': 0.83},\n",
    "     {'color': 'blond', 'confidence': 0.54},\n",
    "     {'color': 'gray', 'confidence': 0.41},\n",
    "     {'color': 'other', 'confidence': 0.21},\n",
    "     {'color': 'red', 'confidence': 0.1},\n",
    "     {'color': 'white', 'confidence': 0.0}]}}},\n",
    " {'faceId': '0c99ce34-eb69-48b2-ae05-b9baec8bc34a',\n",
    "  'faceRectangle': {'top': 40, 'left': 169, 'width': 43, 'height': 43},\n",
    "  'faceAttributes': {'smile': 1.0,\n",
    "   'gender': 'male',\n",
    "   'age': 25.0,\n",
    "   'glasses': 'NoGlasses',\n",
    "   'hair': {'bald': 0.03,\n",
    "    'invisible': False,\n",
    "    'hairColor': [{'color': 'brown', 'confidence': 0.99},\n",
    "     {'color': 'blond', 'confidence': 0.9},\n",
    "     {'color': 'red', 'confidence': 0.48},\n",
    "     {'color': 'gray', 'confidence': 0.32},\n",
    "     {'color': 'other', 'confidence': 0.06},\n",
    "     {'color': 'black', 'confidence': 0.04},\n",
    "     {'color': 'white', 'confidence': 0.0}]}}},\n",
    " {'faceId': 'c5765eb7-cd20-4d7a-b90f-e826aff47f58',\n",
    "  'faceRectangle': {'top': 54, 'left': 251, 'width': 42, 'height': 42},\n",
    "  'faceAttributes': {'smile': 1.0,\n",
    "   'gender': 'female',\n",
    "   'age': 28.0,\n",
    "   'glasses': 'NoGlasses',\n",
    "   'hair': {'bald': 0.02,\n",
    "    'invisible': False,\n",
    "    'hairColor': [{'color': 'brown', 'confidence': 0.99},\n",
    "     {'color': 'black', 'confidence': 0.53},\n",
    "     {'color': 'blond', 'confidence': 0.43},\n",
    "     {'color': 'red', 'confidence': 0.34},\n",
    "     {'color': 'gray', 'confidence': 0.16},\n",
    "     {'color': 'other', 'confidence': 0.12},\n",
    "     {'color': 'white', 'confidence': 0.0}]}}}]\n",
    "\n",
    "# 创建字典\n",
    "glasses = {}\n",
    "smile = {}\n",
    "hairColor = {}\n",
    "age = {}\n",
    "gender = {}\n",
    "\n",
    "# 添加人脸到字典里面\n",
    "count = 0\n",
    "while count < len(face):\n",
    "    glasses[\"Person{}\".format(count + 1)] = face[count]['faceAttributes']['glasses']\n",
    "    smile[\"Person{}\".format(count + 1)] = face[count]['faceAttributes']['smile']\n",
    "    hairColor[\"Person{}\".format(count + 1)] = face[count]['faceAttributes']['hair']['hairColor'][0]['color']\n",
    "    age[\"Person{}\".format(count + 1)] = face[count]['faceAttributes']['age']\n",
    "    gender[\"Person{}\".format(count + 1)] = face[count]['faceAttributes']['gender']\n",
    "    count += 1\n",
    "\n",
    "# 打印字典\n",
    "print(\"眼镜：\", glasses)\n",
    "print(\"微笑指数：\", smile)\n",
    "print(\"头发颜色：\", hairColor)\n",
    "print(\"年龄：\", age)\n",
    "print(\"性别：\", gender)\n",
    "# 眼镜： {'Person1': 'NoGlasses', 'Person2': 'NoGlasses', 'Person3': 'NoGlasses', 'Person4': 'NoGlasses'}\n",
    "# 微笑指数： {'Person1': 1.0, 'Person2': 1.0, 'Person3': 1.0, 'Person4': 1.0}\n",
    "# 头发颜色： {'Person1': 'brown', 'Person2': 'brown', 'Person3': 'brown', 'Person4': 'brown'}\n",
    "# 年龄： {'Person1': 30.0, 'Person2': 32.0, 'Person3': 25.0, 'Person4': 28.0}\n",
    "# 性别： {'Person1': 'male', 'Person2': 'female', 'Person3': 'male', 'Person4': 'female'}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
